/******************************************************************************
*
* This file is part of FreeTrack (http://code.google.com/p/qtfreetrack).
* BY Willy Gardiol (willy@gardiol.org)
*
* FreeTrack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FreeTrack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar.  If not, see <http://www.gnu.org/licenses/>
*
******************************************************************************/

#ifndef FTLIST_H
#define FTLIST_H

#include "IncFreeTrack.h"

class FTList : public QWidget
{
    Q_OBJECT
public:
    explicit FTList(QWidget *parent = 0);

    // Remove all items from the list
    void clear();
    // Place these items in the list (and remove all the old items)
    void populate( const QStringList& );
    // Add one item to the list
    void append( const QString& );
    // Append some items to the list
    void append( const QStringList& );

    // Manage events (for kinetik scroll)
    void mousePressEvent(QMouseEvent *);
    void mouseMoveEvent(QMouseEvent *);
    void mouseReleaseEvent(QMouseEvent *);
    void paintEvent(QPaintEvent *);

signals:
    // Emit when a string is selected
    void selected(const QString&);

private:
    // Are we scrolling?
    bool scrolling;
    // Store mouse Y position during scrolling
    int scroll_start;
    // Screen scroll offset
    int scroll_offset;

    // Store the height of a row
    int row_height;

    // Store selected row
    int row_selected;
    // The items
    QStringList strings;
};

#endif // FTLIST_H
